import Vue from 'vue'
import VuexPersist from 'vuex-persistedstate'
import filterRoutes from '../router/filterRoutes'
//导入vuex插件
import Vuex, { createLogger } from 'vuex'
import routes from '../router/routes'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userinfo: {}
  },
  getters: {
    getRoutes(state) {
      return filterRoutes(routes, state.userinfo.role.permissions);
    }
  },
  mutations: {
    save_userinfo(state, params) {
      state.userinfo = params;
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    createLogger(),
    VuexPersist({ storage: window.localStorage })
  ]
})
